﻿Imports System.Windows.Forms

Public Class frmGISOptions

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub cbo_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboColor1.SelectedIndexChanged, cboColor2.SelectedIndexChanged, cboColor3.SelectedIndexChanged, cboColor4.SelectedIndexChanged, chkInvert.CheckedChanged, cboThreshold.SelectedIndexChanged, cboColor0.SelectedIndexChanged
        picColor.Refresh()
    End Sub

    Private Sub cboThreshold_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboThreshold.SelectedIndexChanged
        txtThreshold.Enabled = cboThreshold.SelectedIndex <> 0
    End Sub

    Private Sub frmGISOptions_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        picColor.Refresh()
    End Sub

    Private Sub picColor_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles picColor.Paint
        Dim colors() As Color = {Color.FromName(Me.cboColor0.Text), Color.FromName(Me.cboColor1.Text), Color.FromName(Me.cboColor2.Text), Color.FromName(Me.cboColor3.Text), Color.FromName(Me.cboColor4.Text)}
        For i As Integer = 0 To picColor.Height - 1
            Dim thiscolor As Color = frmGIS.GradientColor(CSng(i) / picColor.Height, colors, chkInvert.Checked, cboThreshold.SelectedIndex, 0.2)
            e.Graphics.DrawLine(New Pen(thiscolor, 1), 0, i, picColor.Width - 1, i)
        Next
    End Sub

    Private Sub btnReset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnReset.Click
        cboColor0.Text = Color.LightGray.Name
        cboColor1.Text = Color.Green.Name
        cboColor2.Text = Color.Yellow.Name
        cboColor3.Text = Color.Red.Name
        cboColor4.Text = Color.White.Name
        chkInvert.Checked = False
        cboThreshold.SelectedIndex = 0
        txtThreshold.Text = 0.0
    End Sub
End Class
